//
//  album.m
//  mintHome
//
//  Created by 朱彦名 on 16/6/17.
//  Copyright © 2016年 朱彦名. All rights reserved.
//

#import "album.h"
#import "pageEdit.h"
#import "scrollViewOfImage.h"

@interface album ()<UIScrollViewDelegate>

@property (nonatomic, retain) pageEdit *pagePass;

@property (nonatomic, retain) scrollViewOfImage * scroll1;



@end
@implementation album
-(void)dealloc{

    [_pagePass release];
    [_scroll1 release];
    [super dealloc];
    
}
- (instancetype)initWithFrame:(CGRect)frame withImage:(NSArray<UIImage *> *)images {

    self = [super initWithFrame:frame];
    if (self) {
        [self configWithFrame:frame withImage:images];
    }
    return self;

}
- (void)configWithFrame: (CGRect)frame withImage: (NSArray *)images{
 
    self.scroll1 = [[scrollViewOfImage alloc]initWithFrame:frame withImage:images delegate:self];
    [self addSubview:self.scroll1];
    [_scroll1 release];
    
    self.scroll1.delegate = self;
    
    self.pagePass = [[pageEdit alloc]initWithFrame:CGRectMake(0, frame.size.height - 40, frame.size.width, 40)];
    [self addSubview:self.pagePass];
    [_pagePass release];
    self.pagePass.numberOfPages = images.count;
    [self.pagePass addTarget:self action:@selector(handlePage:) forControlEvents:UIControlEventValueChanged];
}
- (void)handlePage: (pageEdit *)page{
    
    [self.scroll1 setContentOffset:CGPointMake(self.bounds.size.width * page.currentPage, 0)animated:YES];

}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    self.pagePass.currentPage = self.scroll1.contentOffset.x / self.bounds.size.width;

}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
